'''
AIVO system

aivo system is our main control

Hold and control Componays

'''
from tools.Logger import Logger

class Aivo:
    def __init__(self):
        self._companys = {}
        pass

    def loadCompany(self,company):
        if company.id in self._companys:
            raise Exception('company id ' + company.id + 'is exist')
        else:
            self._companys[company.id] = company

    def unloadCompany(self,companyid):
        self._companys.pop(companyid)

    def info(self):
        companys = {}
        for key,company in self._companys.items():
            companys[company.id] = company.info()
        return companys

    def companyById(self,id):
        if id in self._companys:
            return self._companys[id]
        else:
            raise Exception('company id ' + id + 'is not exist')
        